Harden SDK v2 telemetry integration paths - #880
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Hardens SDK v2 telemetry and related runtime paths across C++, Python, JavaScript, C#, packaging, downloads, and web-service shutdown.
Changes:
- Adds telemetry redaction, resilient tracking, and API v2 updates.
- Hardens download resume, model/session lifetimes, and streaming shutdown.
- Updates native dependency packaging and deprecates direct OpenAI clients.
Reviewed changes
Copilot reviewed 132 out of 133 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
sdk_v2/python/src/foundry_local_sdk/session.py |
Uses API v2. |
sdk_v2/python/src/foundry_local_sdk/response.py |
Uses API v2. |
sdk_v2/python/src/foundry_local_sdk/request.py |
Uses API v2. |
sdk_v2/python/src/foundry_local_sdk/openai/live_audio_session.py |
Deprecates direct audio session. |
sdk_v2/python/src/foundry_local_sdk/openai/embedding_client.py |
Deprecates embedding client. |
sdk_v2/python/src/foundry_local_sdk/openai/chat_client.py |
Deprecates chat client. |
sdk_v2/python/src/foundry_local_sdk/openai/audio_client.py |
Deprecates audio client. |
sdk_v2/python/src/foundry_local_sdk/items.py |
Uses API v2. |
sdk_v2/python/src/foundry_local_sdk/imodel.py |
Deprecates client factories. |
sdk_v2/python/src/foundry_local_sdk/_native/lib_loader.py |
Hardens native loading. |
sdk_v2/python/src/foundry_local_sdk/_native/api.py |
Retains loader handles; API v2. |
sdk_v2/js/test/manager-dispose.test.ts |
Tests manager lifetime behavior. |
sdk_v2/js/src/openai/liveAudioSession.ts |
Adds deprecation documentation. |
sdk_v2/js/src/openai/embeddingClient.ts |
Adds deprecation documentation. |
sdk_v2/js/src/openai/chatClient.ts |
Adds deprecation documentation. |
sdk_v2/js/src/openai/audioClient.ts |
Adds deprecation documentation. |
sdk_v2/js/src/model.ts |
Deprecates client factories. |
sdk_v2/js/src/index.ts |
Marks deprecated exports. |
sdk_v2/js/src/foundryLocalManager.ts |
Hardens process teardown. |
sdk_v2/js/src/catalog.ts |
Documents disposal behavior. |
sdk_v2/js/script/pack-prebuilds.mjs |
Requires Windows runtime DLLs. |
sdk_v2/js/script/install-native.cjs |
Removes unsupported Linux ARM64. |
sdk_v2/js/script/copy-native.mjs |
Copies DirectML. |
sdk_v2/js/native/src/session.h |
Adds session lifetime leases. |
sdk_v2/js/native/src/model.h |
Propagates manager lifetime state. |
sdk_v2/js/native/src/manager.h |
Tracks active native operations. |
sdk_v2/js/native/src/manager.cc |
Guards manager disposal. |
sdk_v2/js/native/src/catalog.h |
Tracks manager lifetime. |
sdk_v2/cs/src/OpenAI/LiveAudioTranscriptionClient.cs |
Deprecates direct audio session. |
sdk_v2/cs/src/OpenAI/EmbeddingClient.cs |
Deprecates embedding client. |
sdk_v2/cs/src/OpenAI/ChatCompletionRequestResponseTypes.cs |
Suppresses internal obsolete warning. |
sdk_v2/cs/src/OpenAI/ChatClient.cs |
Deprecates chat client. |
sdk_v2/cs/src/OpenAI/AudioTranscriptionRequestResponseTypes.cs |
Suppresses internal obsolete warning. |
sdk_v2/cs/src/OpenAI/AudioClient.cs |
Deprecates audio client. |
sdk_v2/cs/src/IModel.cs |
Deprecates client factories. |
sdk_v2/cs/src/Detail/NativeMethods.cs |
Uses API v2. |
sdk_v2/cs/src/Detail/Model.cs |
Deprecates factory implementations. |
sdk_v2/cpp/test/utils/temp_path.h |
Adds shared temporary paths. |
sdk_v2/cpp/test/sdk_api/shared_test_env.h |
Exposes reserved models. |
sdk_v2/cpp/test/sdk_api/download_test.cc |
Avoids reserved models. |
sdk_v2/cpp/test/internal_api/test_helpers.h |
Reuses temp-path helper. |
sdk_v2/cpp/test/internal_api/telemetry_test.cc |
Tests telemetry redaction. |
sdk_v2/cpp/test/internal_api/session_manager_test.cc |
Tests cache shutdown behavior. |
sdk_v2/cpp/test/internal_api/model_load_manager_test.cc |
Tests loaded-model leases. |
sdk_v2/cpp/test/internal_api/http_download_test.cc |
Adds network download tests. |
sdk_v2/cpp/test/internal_api/file_writer_test.cc |
Uses shared temp paths. |
sdk_v2/cpp/test/internal_api/ep_detector_test.cc |
Tests unknown EP failures. |
sdk_v2/cpp/test/internal_api/cross_process_file_lock_test.cc |
Updates platform lock tests. |
sdk_v2/cpp/test/internal_api/base_model_catalog_test.cc |
Tests catalog refresh behavior. |
sdk_v2/cpp/test/CMakeLists.txt |
Registers download tests. |
sdk_v2/cpp/src/telemetry/telemetry.h |
Distinguishes missing first-token time. |
sdk_v2/cpp/src/telemetry/telemetry_redaction.h |
Adds telemetry scrubbing. |
sdk_v2/cpp/src/telemetry/telemetry_logger.cc |
Scrubs logged errors. |
sdk_v2/cpp/src/telemetry/telemetry_action_tracker.cc |
Contains telemetry failures. |
sdk_v2/cpp/src/telemetry/one_ds_tenant_token.h.in |
Documents secure token input. |
sdk_v2/cpp/src/telemetry/ep_download_tracker.cc |
Contains telemetry failures. |
sdk_v2/cpp/src/telemetry/download_tracker.cc |
Contains telemetry failures. |
sdk_v2/cpp/src/service/web_service.h |
Tracks and joins streams. |
sdk_v2/cpp/src/service/responses_handler.h |
Uses loaded-model leases. |
sdk_v2/cpp/src/service/handler_utils.h |
Scrubs agents; aborts SSE. |
sdk_v2/cpp/src/service/embeddings_handler.cc |
Transfers model lease. |
sdk_v2/cpp/src/service/chat_completions_handler.h |
Uses loaded-model leases. |
sdk_v2/cpp/src/service/chat_completions_handler.cc |
Adds cancellable streaming. |
sdk_v2/cpp/src/service/audio_transcriptions_handler.h |
Uses loaded-model leases. |
sdk_v2/cpp/src/service/audio_transcriptions_handler.cc |
Adds cancellable streaming. |
sdk_v2/cpp/src/platform/windows/file_io.cc |
Implements Windows file I/O. |
sdk_v2/cpp/src/platform/windows/cross_process_file_lock.cc |
Implements Windows locking. |
sdk_v2/cpp/src/platform/posix/file_io.cc |
Implements POSIX file I/O. |
sdk_v2/cpp/src/platform/file_io.h |
Defines file-I/O abstraction. |
sdk_v2/cpp/src/platform/cross_process_file_lock.h |
Defines process lock abstraction. |
sdk_v2/cpp/src/platform/cross_process_file_lock.cc |
Implements lock waiting. |
sdk_v2/cpp/src/model.h |
Adds atomic variant selection. |
sdk_v2/cpp/src/model.cc |
Synchronizes variant selection. |
sdk_v2/cpp/src/manager.h |
Synchronizes web-service state. |
sdk_v2/cpp/src/inferencing/session/session.cc |
Uses model leases and cancellation. |
sdk_v2/cpp/src/inferencing/session/session_manager.h |
Tracks cached model identity. |
sdk_v2/cpp/src/inferencing/session/session_manager.cc |
Hardens cache shutdown. |
sdk_v2/cpp/src/inferencing/model_load_manager.h |
Defines loaded-model lease. |
sdk_v2/cpp/src/inferencing/model_load_manager.cc |
Implements safe unload leasing. |
sdk_v2/cpp/src/inferencing/generative/embeddings/embeddings_session.h |
Accepts transferred lease. |
sdk_v2/cpp/src/inferencing/generative/embeddings/embeddings_session.cc |
Handles transferred lease. |
sdk_v2/cpp/src/inferencing/generative/chat/chat_session.h |
Accepts transferred lease. |
sdk_v2/cpp/src/inferencing/generative/chat/chat_session.cc |
Handles transferred lease. |
sdk_v2/cpp/src/inferencing/generative/audio/audio_session.h |
Accepts transferred lease. |
sdk_v2/cpp/src/inferencing/generative/audio/audio_session.cc |
Handles transferred lease. |
sdk_v2/cpp/src/ep_detection/webgpu_ep_bootstrapper.h |
Exposes platform support. |
sdk_v2/cpp/src/ep_detection/webgpu_ep_bootstrapper.cc |
Restricts supported platforms. |
sdk_v2/cpp/src/ep_detection/ep_utils.h |
Adds dynamic binary verification. |
sdk_v2/cpp/src/ep_detection/ep_utils.cc |
Verifies binary vectors. |
sdk_v2/cpp/src/ep_detection/ep_detector.h |
Retains immutable snapshots. |
sdk_v2/cpp/src/ep_detection/ep_detector.cc |
Publishes safe EP snapshots. |
sdk_v2/cpp/src/ep_detection/cuda_ep_bootstrapper.cc |
Verifies CUDA package contents. |
sdk_v2/cpp/src/download/file_writer.h |
Uses platform file handles. |
sdk_v2/cpp/src/download/file_writer.cc |
Delegates platform file I/O. |
sdk_v2/cpp/src/download/download_manager.cc |
Hardens legacy resume recovery. |
sdk_v2/cpp/src/download/blob_downloader.h |
Adds blob identity and metrics. |
sdk_v2/cpp/src/download/blob_download_state.h |
Persists blob identity. |
sdk_v2/cpp/src/catalog/catalog_client.cc |
Redacts catalog failures. |
sdk_v2/cpp/src/catalog/base_model_catalog.h |
Tracks forced refreshes. |
sdk_v2/cpp/src/catalog/base_model_catalog.cc |
Merges refreshed variants. |
sdk_v2/cpp/src/catalog/azure_model_catalog.cc |
Buckets private endpoints. |
sdk_v2/cpp/src/c_api.cc |
Adds stable snapshots and API v2. |
sdk_v2/cpp/run_coverage.ps1 |
Expands disabled-test coverage. |
sdk_v2/cpp/nuget/pack.py |
Packages DirectML. |
sdk_v2/cpp/include/foundry_local/foundry_local_c.h |
Declares API v2. |
sdk_v2/cpp/docs/ResumableDownloadsPlan.md |
Updates lock locations. |
sdk_v2/cpp/CMakeLists.txt |
Updates dependencies and platform sources. |
sdk_v2/cpp/cmake/FindWinMLEpCatalog.cmake |
Uses FetchContent packaging. |
sdk_v2/cpp/cmake/FindOnnxRuntimeGenAI.cmake |
Hardens local package handling. |
sdk_v2/cpp/cmake/FindOnnxRuntime.cmake |
Hardens runtime package handling. |
sdk_v2/cpp/build.py |
Redacts commands and token input. |
memories/repo/openai-direct-clients-deprecated.md |
Records deprecation guidance. |
.pipelines/v2/templates/steps-pack-js.yml |
Includes dependency manifest. |
.pipelines/v2/templates/steps-pack-cpp-sdk.yml |
Packages runtime dependencies. |
.pipelines/v2/templates/steps-build-windows.yml |
Stages Windows dependencies. |
.pipelines/v2/templates/steps-build-python.yml |
Filters wheel native assets. |
.pipelines/v2/templates/steps-build-macos.yml |
Stages macOS runtimes. |
.pipelines/v2/templates/steps-build-linux.yml |
Stages Linux runtimes. |
.pipelines/v2/templates/steps-build-js.yml |
Stages DirectML for JS. |
| if (!it->second->HasExplicitVariantSelection()) { | ||
| it->second->SelectDefaultVariant(); |
|
|
||
| # Include DISABLED_ tests (e.g. the real-network http_download manifest test) so the unit step | ||
| # covers code paths that are network-gated off by default. Mirrors the integration step below. | ||
| $unitArgs += "--gtest_also_run_disabled_tests" |
| if (!create_dir) { | ||
| path_ = std::move(candidate); | ||
| return; | ||
| } |
| if (err == ERROR_SHARING_VIOLATION || err == ERROR_LOCK_VIOLATION || err == ERROR_ACCESS_DENIED) { | ||
| // SHARING/LOCK_VIOLATION: another handle already holds the share-none | ||
| // lock. ACCESS_DENIED: the holder is mid-release — FILE_FLAG_DELETE_ON_CLOSE | ||
| // puts the file into STATUS_DELETE_PENDING during the close window, and a | ||
| // concurrent open of a delete-pending file is reported as ACCESS_DENIED. | ||
| // All three mean "another process has it"; treat as contention so the | ||
| // caller retries. (A genuine permission error also lands here and would | ||
| // poll until timeout, but the directory was just created successfully so | ||
| // that is improbable.) |
| warnings.warn( | ||
| "The OpenAI direct client is deprecated and will be removed at the end of 2026; use " | ||
| "ChatSession. OpenAI types remain supported for the web-server path.", | ||
| DeprecationWarning, | ||
| stacklevel=2, | ||
| ) |
| warnings.warn( | ||
| "The OpenAI direct client is deprecated and will be removed at the end of 2026; use " | ||
| "AudioSession. OpenAI types remain supported for the web-server path.", | ||
| DeprecationWarning, | ||
| stacklevel=2, | ||
| ) |
| warnings.warn( | ||
| "The OpenAI direct client is deprecated and will be removed at the end of 2026; use " | ||
| "EmbeddingsSession. OpenAI types remain supported for the web-server path.", | ||
| DeprecationWarning, | ||
| stacklevel=2, | ||
| ) |
| warnings.warn( | ||
| "The OpenAI direct client is deprecated and will be removed at the end of 2026; use " | ||
| "AudioSession. OpenAI types remain supported for the web-server path.", | ||
| DeprecationWarning, | ||
| stacklevel=2, | ||
| ) |
Bring PR #879's request-context, session-create timing, and telemetry contract fixes into the stacked hardening branch while preserving #880's session construction implementations. Files changed: - sdk_v2/cpp/src/download/download_manager.cc - sdk_v2/cpp/src/inferencing/session/session.* - sdk_v2/cpp/src/telemetry/telemetry.h Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 297bc539-5f7f-4a70-9411-48e91a5bf532
Bring PR #879 round-5 Copilot fixes into the stacked hardening branch while preserving stack-only packaging hardening. Keep #880's stricter unknown-EP behavior and include unmatched requested EPs in aggregate telemetry failure counts. Files changed: - sdk_v2/cpp/vcpkg.json - sdk_v2/cpp/src/ep_detection/ep_detector.cc - sdk_v2/cpp/src/inferencing/session/session.cc - sdk_v2/cpp/src/inferencing/generative/{chat,audio,embeddings}/*session* - sdk_v2/cpp/src/service/{chat_completions,audio_transcriptions}_handler.cc - sdk_v2/cpp/src/service/handler_utils.h - sdk_v2/cpp/src/telemetry/{invocation_context,one_ds_telemetry,telemetry}.cc - sdk_v2/cpp/test/internal_api/{ep_detector,telemetry}_test.cc Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 297bc539-5f7f-4a70-9411-48e91a5bf532
Bring PR #879 round-6 Copilot fixes into the hardening stack while preserving #880's stricter unknown-EP behavior. EP telemetry: cancellation records skipped provider phases and unmatched requested EPs remain aggregate failures in the stack. Status telemetry: add/reset sampler state for deterministic status heartbeat tests. Files changed: - sdk_v2/cpp/src/ep_detection/ep_detector.cc - sdk_v2/cpp/test/internal_api/ep_detector_test.cc - sdk_v2/cpp/src/service/web_service.{h,cc} - sdk_v2/cpp/test/internal_api/web_service_test.cc Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 297bc539-5f7f-4a70-9411-48e91a5bf532
Bring the ONNX Runtime-inspired ProcessInfo event into #880 while preserving the hardening stack's existing telemetry redaction tests. Files changed: - sdk_v2/cpp/src/manager.cc - sdk_v2/cpp/src/telemetry/{telemetry,telemetry_logger,one_ds_telemetry,telemetry_metadata}.{h,cc} - sdk_v2/cpp/test/internal_api/telemetry_test.cc Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 297bc539-5f7f-4a70-9411-48e91a5bf532
Bring the persistent hashed device-id support from #879 into #880 while preserving the hardening stack's telemetry redaction behavior. Files changed: - sdk_v2/cpp/CMakeLists.txt - sdk_v2/cpp/src/telemetry/device_id.{h,cc} - sdk_v2/cpp/src/telemetry/one_ds_telemetry.cc - sdk_v2/cpp/src/telemetry/{telemetry,telemetry_logger,telemetry_metadata}.cc - sdk_v2/cpp/src/util/sha256.{h,cc} - sdk_v2/cpp/test/internal_api/telemetry_test.cc Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 297bc539-5f7f-4a70-9411-48e91a5bf532
Bring the final telemetry core docs/guards into #880: Privacy.md, UWP 1DS exclusion, and OneDsTelemetry initialized_ publish ordering. Files changed: - sdk_v2/cpp/docs/Privacy.md - sdk_v2/cpp/CMakeLists.txt - sdk_v2/cpp/vcpkg.json - sdk_v2/cpp/src/telemetry/one_ds_telemetry.cc Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 297bc539-5f7f-4a70-9411-48e91a5bf532
Bring all remaining #879 telemetry updates into #880, including FOUNDRY_TESTING_MODE removal, privacy-doc updates, and the OneDsTelemetry merge resolution. Files changed: - sdk_v2/cpp/docs/Privacy.md - sdk_v2/cpp/src/telemetry/one_ds_telemetry.cc - sdk_v2/cpp/src/telemetry/telemetry_environment.{h,cc} - sdk_v2/cpp/src/telemetry/telemetry_logger.h - sdk_v2/cpp/src/telemetry/telemetry_metadata.{h,cc} - sdk_v2/cpp/test/internal_api/telemetry_test.cc Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 297bc539-5f7f-4a70-9411-48e91a5bf532
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 112 out of 112 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
sdk_v2/cpp/src/catalog/base_model_catalog.cc:127
- This check and the following default selection are not atomic with
Model::SelectVariant(). A concurrent caller can explicitly select a variant afterHasExplicitVariantSelection()returns false but beforeSelectDefaultVariant()acquiresstate_mutex_; the refresh then overwrites that selection and resets the explicit flag. Please expose a model operation that checks the flag and selects the default while holdingstate_mutex_once, and call that here.
if (!it->second->HasExplicitVariantSelection()) {
it->second->SelectDefaultVariant();
}
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 112 out of 112 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
sdk_v2/cpp/src/telemetry/telemetry_redaction.h:84
- Absolute POSIX paths with a single component are not scrubbed: for example,
failed to open /secret.txtproduces only one segment, so the path is uploaded unchanged. Treat a slash at a token boundary as an absolute path even with one segment; keep the two-segment requirement only for embedded/relative slash tokens such asand/or.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 112 out of 112 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
sdk_v2/cpp/src/catalog/base_model_catalog.cc:126
- The explicit-selection check is not synchronized with
SelectDefaultVariant(). A concurrentSelectVariant()can set an explicit choice after this load but beforeSelectDefaultVariant()acquires the model mutex, so the refresh then overwrites the user's selection and clears the flag. Make the “select default only if not explicitly selected” decision atomic underModel::state_mutex_(for example, a dedicated model method) rather than splitting it across these calls.
if (!it->second->HasExplicitVariantSelection()) {
it->second->SelectDefaultVariant();
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 112 out of 112 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
sdk_v2/cpp/src/download/download_manager.cc:397
- A sidecar-safe retry skips every full-size file whose per-blob
.dlstatewas deleted on completion, but no completed-file blob identity is persisted or revalidated here. If a blob is replaced with different content of the same size between the failed attempt and retry, this keeps the old blob while downloading the remaining blobs from the new container version, producing a mixed/corrupt model cache. Persist and compare completed identities, or redownload no-sidecar files on any model-level retry; the currentRetrySkipsCompletedBlobWithoutSidecartest should also cover a same-size identity change.
download_opts.skip_completed_files = can_skip_completed_files;
download_opts.require_completed_file_identity = had_download_signal && !can_skip_completed_files;
sdk_v2/cpp/src/telemetry/telemetry_redaction.h:84
- This only treats slash paths as sensitive after two non-empty segments (and the backslash branch similarly requires two separators), so common relative paths such as
alice/model.onnxorAlice\\secret.txtare uploaded unchanged in exception telemetry. Those paths can contain usernames or customer file names. Please also redact one-separator relative path tokens using a bounded heuristic (for example, token boundaries plus a filename-like suffix) and add corresponding tests.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 112 out of 112 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
sdk_v2/cpp/src/download/blob_downloader.cc:515
- When identity revalidation is required, an empty listing identity is the least verifiable case, but this condition lets a same-size file be skipped.
BlobItemInfo::blob_identityis explicitly optional/empty, so an incomplete-directory repair can retain stale bytes whenever the backend does not return an ETag/version. Redownload unconditionally whenrequire_completed_file_identityis set; there is no persisted identity for a sidecar-free file to compare.
if (require_completed_file_identity && !blob.blob_identity.empty()) {
return true;
}
Carry forward the runtime packaging, download, catalog, shutdown, streaming, binding lifetime, and test hardening from PR #880 on top of the latest telemetry core branch. Drop the obsolete telemetry ABI/config/redaction churn so #879 remains the source of truth for non-essential telemetry semantics and backend-owned cleanup. Files changed: - .github/workflows/samples-integration-test.yml - .pipelines/v2/templates/* - sdk_v2/cpp/** - sdk_v2/js/** - sdk_v2/python/** - package metadata under sdk/js and www Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 297bc539-5f7f-4a70-9411-48e91a5bf532
|
Closing for now while the independent hardening pieces are split into draft PRs. |
Summary
Notes
bhamehta/flcore/1ds-telemetry-core.